<template>
	<view class="wrap">
		<view class="content">
			<view class="list">
				<view class="item"><textarea maxlength="100" v-model="content" placeholder="请输入您的意见或建议…"
						style="padding: 5rpx;"></textarea></view>
				<view class="item">

					<picker @change="bindPickerChange" :value="typeList[index]" :range="typeList">
						<view class="uni-input">{{typeList[index]}}</view>
					</picker>
				</view>

				<u-button custom-style="width:100px" type="primary" text="提交" @tap="save"></u-button>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				type: '',
				content: '',
				//绑定类型
				index: 0,
				typeList: ["小程序体验", "加测试题目", "其他建议"]
			};
		},
		onShow() {

		},
		onLoad(e) {
			const app = getApp()
			app.globalData.ttChaping('rcjfk6qb3py5p0z93g') // 2024年9月3日 增加反馈页面插屏
		},
		onPullDownRefresh() {},
		methods: {

			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.detail.value)
				this.index = e.detail.value
				this.type = e.detail.value
			},
			/*提交*/
			save() {
				if (this.content == '') {
					this.$app.alert('请输入您的意见或建议');
					return;
				}

				if (this.content == '看广告') {
					const app = getApp()
					app.globalData.playAd()
					return
				}

				uni.showLoading({
					title: '提交中…'
				});

				let remark = ''
				uni.getSystemInfo({
					success: function(res) {
						console.info('res==>', res)
						let info = res
						remark = info.deviceType + " " + info.deviceBrand + " " + info.deviceModel + " " + info
							.osName + "  " + info.appId + " " + info.uniPlatform + " " + info.ua + " " + info
							.appVersion;
					}
				})

				console.info('uniPlatform=>', remark)

				let data = {
					content: this.content,
					remark: remark,
					type: this.type
				}
				let url = this.$app.apiPath.common.feedback;
				//console.info('===>',url);

				this.$app.post(url, data).then(res => {
					if (res.code == 200) {

						this.$app.alert('您的意见我已经收到,感谢您的反馈', '', '/pages/my/my', 'switchTab');
						uni.hideLoading()
						//uni.navigateBack()
					}
				}, err => {
					uni.hideLoading()
				})


			}
		}
	};
</script>

<style scoped lang="scss">
	.list {
		position: fixed;
		width: 100%;

		.item {
			padding: 50upx 20upx 20rpx;
			background: #fff;

			textarea {
				border: 1px solid #eeeeee;
				height: 350rpx;
				font-size: 32rpx;
				width: 100%;
			}
		}


	}
</style>